package bomb;

import java.io.IOException;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
import org.newdawn.slick.state.StateBasedGame;
import bomb.logic.levels.*;
import bomb.menus.*;
import bomb.utils.Arquivo;

/*Jogo criado para a disciplina SCC-604, segundo semestre de 2011
 * Pelos alunos:
 * Mauricio Fonseca
 * Rafael de Sousa
 * Rodrigo Camargo
 */
public class Game extends StateBasedGame{

    public static final int MENUSTATE = 201;
    public static final int MENUJOGOSTATE = 202;
    public static final int SCORESSTATE = 203;
    public static final int LEVELSELECTSTATE = 204;
    public static final int LEVEL1STATE = 0;
    public static final int LEVEL2STATE = 1;
    public static final int LEVEL3STATE = 2;
    public static final int LEVEL4STATE = 3;
    public static final int LEVEL5STATE = 4;
    public static final int LEVEL6STATE = 5;
    
    
    private static int faseAtual = 0;
    private static Sound toq = null;
    private static Sound arrasto = null;
    private static Sound placed = null;
    private static Sound bomb = null;
    private static Sound fundo = null;
    private static Sound passo = null;
    private static Sound foguete = null;
    private static Sound sheep = null;
    private static Image parabens = null;
    private static boolean musicOn = false;
    private static boolean soundOn = true;
    private static boolean paused = false;
    
    public Game() throws SlickException
    {
        super("BombQuest");
        this.addState(new Menu(MENUSTATE));
        this.addState(new Level1(LEVEL1STATE));
        this.addState(new MenuJogo(MENUJOGOSTATE));
        this.addState(new TelaScores(SCORESSTATE));
        this.addState(new Level2(LEVEL2STATE));
        this.addState(new LevelSelect(LEVELSELECTSTATE));
        this.addState(new Level3(LEVEL3STATE));
        this.addState(new Level4(LEVEL4STATE));
        this.addState(new Level5(LEVEL5STATE));
        this.addState(new Level6(LEVEL6STATE));
        this.enterState(MENUSTATE);
        
        toq = new Sound("src/sounds/toc00.wav");
        arrasto = new Sound("src/sounds/drag00.wav");
        placed = new Sound("src/sounds/click00.wav");
        fundo = new Sound("src/sounds/overworld00.wav");
        bomb = new Sound("src/sounds/bomb00.wav");
        passo = new Sound("src/sounds/step00.wav");
        foguete = new Sound("src/sounds/foguete.wav");
        sheep = new Sound("src/sounds/sheep.wav");
    
    }
 
    @Override
    public void initStatesList(GameContainer gc) throws SlickException {
        this.getState(MENUSTATE).init(gc, this);
        this.getState(MENUJOGOSTATE).init(gc, this);
        this.getState(LEVEL1STATE).init(gc, this);
        this.getState(SCORESSTATE).init(gc, this);
        this.getState(LEVEL2STATE).init(gc, this);
        this.getState(LEVELSELECTSTATE).init(gc, this);
        this.getState(LEVEL3STATE).init(gc, this);
        this.getState(LEVEL4STATE).init(gc, this);
        this.getState(LEVEL5STATE).init(gc, this);
        this.getState(LEVEL6STATE).init(gc, this);
        parabens = new Image("src/images/complete.png");
        
    }
    
    public static void main(String[] args) throws SlickException, IOException {
        AppGameContainer app = new AppGameContainer(new Game());
        app.setDisplayMode(400, 400, false);
        //carregar os scores
        Arquivo.carregar();
        app.setShowFPS(false);
        music();
        app.start();
        
         
    }
    
    public static void music(){
        if(!musicOn){
            fundo.loop();
            musicOn = true;
        } 
        else {
            
            fundo.stop();
            musicOn = false;
        }
    }
    public static  boolean isMusic(){
        return musicOn;
    }
    public static void setFaseAtual(int state){
        faseAtual = state;
    }
    public static int getFaseAtual(){
        return  faseAtual;
    }
    public static void sound(){
        if(!soundOn){
            soundOn = true;
        } 
        else {
            soundOn = false;
        }
    }
    public static boolean isSound(){
        return soundOn;
    }
    public static void clickSound(){
        if(soundOn){
            toq.play();
        }
    }
    public static void arrastoSound(){
        if(soundOn){
            arrasto.play();
        }
    }
    public static void placedSound(){
        if(soundOn){
            placed.play();
        }
    }
    public static void completeSound(){
        if(soundOn){
            bomb.play();
        }
    }
    public static void sheepSound(){
        if(soundOn){
            sheep.play();
        }
    }
    public static void passoSound(){
        if(soundOn){
            passo.play();
        }
    }
    public static void fogueteSound(){
        if(soundOn){
            foguete.play();
        }
    }
    public static Image getParabens(){
        return parabens;
    }
    public static boolean isPaused(){
    	return paused;
    }
    public static void pause(){
    	if(!paused){
    		paused = true;
    	}
    	else paused = false;
    }
}